var app = getApp();

Page({
    data: {
        CategoryTit:"",
        CategoryTitLength:"",
        selectedTitle: "0",
        scrollSite:0,
        imgUrl: app.globalData.imgUrl,
        typeData: [],
    },
    onLoad: function (options) {
        var that = this;
        that.getServiceCategory();
        that.setData({
            navH: app.globalData.navHeight,
            marH: app.globalData.navHeight + 20,
            scrollH:wx.getSystemInfoSync().windowHeight-app.globalData.navHeight-40
        });
    },
    onShareAppMessage() {
        return {
          title: '在海花岛这样订房也不错，快看快约！',
          //path: '/pages/serve/serve-search'
          //path: 'pages/index/index?url=/pages/serve/serve-search'
          path: 'pages/index/index?url=/pages/index/index'
        }
    },
    navBack: function () {
        wx.navigateBack({
          delta: 1
        })
    },
    bindtap: function (e) {
        this.setData({
            selectedTitle: e.currentTarget.id,
            scrollSite:e.currentTarget.id*200
        });
    },
    scroll(e){
        var scrollIdx=parseInt(e.detail.scrollTop/200);
        this.setData({
            selectedTitle:scrollIdx
        });
    },
    scrollUpper(e){
        this.setData({
            selectedTitle: 0
        });
    },
    scrollLower(e){
        var that=this;
        this.setData({
            selectedTitle:that.data.CategoryTitLength-1
        });
    },
    getServiceCategory: function () {
        var that=this;
        wx.request({
            url: app.globalData.apiHost + "/api/index/serviceCategoryList",
            data: {
                type: 0
            },
            header: {
                'content-type': 'application/json'
            },
            method: "GET",
            dataType: "json",
            success: function (res) {
                if (res.statusCode === 200) {
                    var CategoryTitData=res.data.data;
                    var CategoryTitLength=res.data.data.length;
                    that.setData({
                       CategoryTit: CategoryTitData,
                       CategoryTitLength:CategoryTitLength
                    })  
                }
            },
            
        })
    }
})